package cn.hfatec.shms.web.vip.vipXh.service;

import java.util.List;
import java.util.HashMap;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hfatec.base.BaseDao;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.shms.web.vip.vipXh.model.VipXh;
import cn.hfatec.shms.web.vip.vipXh.dao.VipXhDao;
import cn.hfatec.shms.web.vip.vipXh.model.VipXhParams;

import javax.annotation.Resource;



/**
 *
 * @author hfatec
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Service("VipXhService")
public class VipXhService {

    public static final String BEAN_ID = "VipXhService";

    //注入Dao层
    @Resource(name = "VipXhDao")
    private VipXhDao vipXhDao;

    //注入BaseDao
    @Resource(name = "BaseDao")
    private BaseDao baseDao;

    /**
     *
     * 查询数据
     *
     * @param vipXhParams
     * @param page
     *
     */
    @Transactional
    public Table queryVipXhTable(VipXhParams vipXhParams, Page page){

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("params", vipXhParams);
        return baseDao.queryTableByPage("queryVipXh", params, page);
    }

    /**
     *
     * 插入数据
     * @param vipXh
     *
     */
    @Transactional
    public void saveVipXh(VipXh vipXh) {
        if(vipXh.getId() != null) {
            VipXh result = getVipXh(vipXh.getId());
            if(result != null) {
                vipXhDao.update(vipXh);
            } else {
                vipXhDao.insert(vipXh);
            }
        } else {
            vipXhDao.insert(vipXh);
        }
    }

    /**
     *
     * 删除数据
     * @param id
     *
     */
    @Transactional
    public void deleteVipXh(Integer id) {

        vipXhDao.delete(id);
    }

    /**
     *
     * 删除数据
     * @param vipXhList
     *
     */
    @Transactional
    public void deleteVipXhBatch(List<String> vipXhList) {
        for(String id : vipXhList) {
            deleteVipXh(Integer.valueOf(id));
        }
    }

    /**
     *
     * 根据ID获取数据
     * @param id
     *
     */
    @Transactional
    public VipXh getVipXh(Integer id) {

        return vipXhDao.getVipXhById(id);
    }
}